package
{
	import code.OutDisplay;
	import com.sociodox.theminer.TheMiner;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.sampler.getSize;
	import flash.text.TextField;

	public class ZmyObjectTest extends Sprite
	{
		
		private var circle:Sprite;
		private var mX:Number;
		private var mY:Number;
		private var cX:Number;
		private var cY:Number;
		public function ZmyObjectTest()
		{
//			this.addChild(new TheMiner());
			var circle:Sprite = new Sprite();
//			circle.graphics.beginFill(0xFFCC00);
//			circle.graphics.drawCircle(0, 0, 40);
//			trace(getSize(circle));
//			
//			var square:Sprite = new Sprite();
//			square.graphics.beginFill(0xCCFF00);
//			square.graphics.drawRect(200, 0, 100, 100);
//			
//			circle.hitArea = square;
//			square.mouseEnabled = false;
//			
//			circle.addEventListener(MouseEvent.CLICK, clicked);
//			
//			function clicked(event:MouseEvent):void{
//				trace(event.target == circle); // true
//				trace(event.target == square); // false
//			}
//			
//			addChild(circle);
//			addChild(square);
//			ZmyObjectTest.shake(square,22);
			
			
			circle = new Sprite();
			circle.name = "circle";
			circle.graphics.beginFill(0xFFCC00);
			circle.graphics.drawCircle(0, 0, 40);
			addChild(circle)
			
//			circle.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown) 
//			circle.addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
//			circle.addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
//			circle.addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
////			mc.addEventListener(MouseEvent.MOUSE_OVER,onMCMouseOver);
//			circle.addEventListener(MouseEvent.CLICK,onCircleClick,true);
//			mc.addEventListener(MouseEvent.CLICK,onMcClick);
//			stage.addEventListener(MouseEvent.CLICK,onStageClick);
			
//			new OutDisplay(MouseEvent.CLICK,stage,circle).addEventListener(Event.CANCEL,fun);
			
			function fun(e:Event):void{
				e.currentTarget.removeEventListener(Event.CANCEL,fun);
				removeChild(circle);
			}
			

			trace(5&2);
		}
		
		protected function onStageClick(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			trace("stage点击了" + event.target.name);
			mX = this.mouseX;
			mY = this.mouseY;
			cX = circle.x;
			cY = circle.y;
		}
		
		protected function onMcClick(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			trace("MC点击了。"+ event.target.name);
			event.stopPropagation();
//			event.stopImmediatePropagation();
		}
		
		protected function onCircleClick(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			trace("circle点击了"+ event.target.name);
		}		
		
		protected function onMCMouseOver(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			trace("MC移动到");
		}
		
		protected function onMouseOut(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			trace("circle移动出");
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			trace("circle移动到");
		}		
		
		
		
		private function mouseDown(event:MouseEvent):void {
			circle.startDrag();
		}
		
		private function mouseReleased(event:MouseEvent):void {
			circle.stopDrag();
		}
		
	}
}